<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${AppBaseInfo.appName}</title>
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<script type="text/javascript">

     function doCopyProjectConf(){
 		var copyOptionValue = $('input[name="copyOption"]:checked').val();
 		if($('#appId').val() == ""){
 	 		alert("请输入目标应用编号!");
 	 		return;
 		}
		if(copyOptionValue == "2"){
	 		if($('#appName').val() == ""){
	 	 		alert("请输入目标应用名称!");
	 	 		return;
	 		}
		}
		$.ajax( {
			type : 'post',
			url : '${ctx}/appmgr/copyProjectConf',
			dataType : "json",
			data : $("#baseinfo").serialize(),
			async : false,
			success : function(data) {//返回json结果
				var result = data.model.ec;
				if (result != 0) {
					alert(data.model.em);
				} else {
					alert("复制应用配置成功!");
					try {
						opener.document.location.reload(true);
					} catch (e) {

					}
					window.close();
				}
			}
		});	       
     }

     function doCopyOptionChange(){
    	 var copyOptionValue = $('input[name="copyOption"]:checked').val();
    	 // 如果复制到指定工程,则只需要填写应用编号
    	 if(copyOptionValue == "1"){
			$('#appId').attr('readonly',false);
			$('#appName').attr('readonly',true);
    	 } else {
 			$('#appId').attr('readonly',false);
			$('#appName').attr('readonly',false);
    	 }
     }

</script>
</head>
<body>
<div class="panel panel-default ">
   <div class="panel-heading">
      <h3 class="panel-title">
          复制[${AppBaseInfo.appName}(${AppBaseInfo.appId})]应用配置
      </h3>
   </div>
   <div class="panel-body">
<form class="form-horizontal" role="form" id="baseinfo" name="baseinfo"  method="post">
					<input type="text" hidden="true" name="srcAppId" value="${AppBaseInfo.appId}"/>
                    <fieldset>
                       <div class="form-group">
                       		<label class="col-xs-2 control-label" for="ds_username"></label>
							<label
								class="checkbox-inline"> <input type="radio"
								name="copyOption" id="copyOption" value="1" onchange="doCopyOptionChange()">
									复制到指定工程
							</label>
							<label
								class="checkbox-inline"> <input type="radio"
								name="copyOption" id="copyOption" value="2" checked onchange="doCopyOptionChange()">
									复制为新的应用工程
							</label>
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="ds_username">目标应用编号</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appId" name="appId" type="text" value="" placeholder="输入目标应用编号"/>
                          </div>
                          <label class="col-xs-2 control-label" for="ds_password">目标应用名称</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appName" name="appName" type="text" value="" placeholder="输入目标应用名称"/>
                          </div>
                       </div>
                    </fieldset>
			<table class="table table-bordered" style="" width="100%" cellspacing="1" cellpadding="0" border="0">
				<thead>
					<tr align="center" class="active">
					    <td width="80">选择</td>
						<td>应用配置项</td>
					    <td width="80">选择</td>
						<td>应用配置项</td>						
					</tr>
				</thead>				
				<tbody>
					<tr align="center">
						<td><input type="checkbox" name="appOption" id="appOption" value="1" checked></input></td>
						<td>基本设置</td>
						<td><input type="checkbox" name="appOption" id="appOption" value="2" checked></input></td>
						<td>证书设置</td>						
					</tr>				
					<tr align="center">
						<td><input type="checkbox" name="appOption" id="appOption" value="3" checked></input></td>
						<td>风格设置</td>
						<td><input type="checkbox" name="appOption" id="appOption" value="4" checked></input></td>
						<td>通讯设置</td>
					</tr>
					<tr align="center">
						<td><input type="checkbox" name="appOption" id="appOption" value="5" checked></input></td>
						<td>模块设置</td>
						<td><input type="checkbox" name="appOption" id="appOption" value="6" checked></input></td>
						<td>交易设置</td>
					</tr>										
					<tr align="center">
						<td><input type="checkbox" name="appOption" id="appOption" value="7" checked></input></td>
						<td>资源设置</td>
						<td><input type="checkbox" name="appOption" id="appOption" value="8" checked></input></td>
						<td>统一认证设置</td>
					</tr>
					<tr align="center">
						<td><input type="checkbox" name="appOption" id="appOption" value="9" checked></input></td>
						<td>设备准入设置</td>
						<td></td>
						<td></td>
					</tr>
				</tbody>
			</table>                        
                 	<p>&nbsp;</p>

					<div class="form-group">
						<div class="col-xs-5"></div>
						<div class="col-xs-5">
							<button type="button" class="btn btn-default" onclick="doCopyProjectConf()">&nbsp;&nbsp;开始复制&nbsp;&nbsp;</button>
							<button type="button" class="btn btn-default"  onclick="window.close()">&nbsp;&nbsp;&nbsp;&nbsp;关&nbsp;&nbsp;&nbsp;&nbsp;闭&nbsp;&nbsp;&nbsp;&nbsp;</button>
						</div>
					</div>
                    <br></br>
                </form>
	</div>
	</div>
</body>
</html>
